package org.kzwl.service.app.impl;

import org.kzwl.comm.advice.Consts;
import org.kzwl.comm.utils.MinIoUtil;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

@Component
public class MinIoService {


    public void init() {
        MinIoUtil.init();
    }


    public String getFilePath(String pathName) {
        return MinIoUtil.getFileUrl(Consts.Minio.BucketName, pathName);
    }

    public String upload( MultipartFile file) {
        String upload = MinIoUtil.upload(Consts.Minio.BucketName, file);
        String answer = upload.replace("localhost", Consts.Minio.repUrl);
        answer = answer.substring(0,answer.indexOf("?"));
        return answer;
    }


}
